package com.bancomer.batch.converters;

import java.io.IOException;

import com.bancomer.batch.pojo.Detail;
import com.bancomer.batch.pojo.Summary;
import com.bancomer.batch.pojo.SummaryDetail;
import com.blackbear.flatworm.FileCreator;
import com.blackbear.flatworm.errors.FlatwormCreatorException;

public class FlatWormWriter {
	public static void create(String config, String output, AuditAlert auditAlert) throws FlatwormCreatorException, IOException {
		FileCreator fileCreator = new FileCreator(config,output);
        fileCreator.open();
        fileCreator.setRecordSeperator("\n");
		for (Summary summary : auditAlert.getSummary() ) {
			fileCreator.setBean("resumen", summary);
            fileCreator.write("TSALAR");
		}
		for (Detail detail : auditAlert.getDetail() ) {
			fileCreator.setBean("desglose", detail);
	        fileCreator.write("TSALAD");
		}
		/*for (SummaryDetail summaryDetail : auditAlert.getSummaryDetail()) {
			for (Summary summary : summaryDetail.getAuditAlertSummary().getSummary()) {
				fileCreator.setBean("resumen", summary);
	            fileCreator.write("TSALAR");
			}
			for (Detail detail : summaryDetail.getAuditAlertDetail().getDetail()) {
				fileCreator.setBean("desglose", detail);
		        fileCreator.write("TSALAD");
			}
		}*/
		fileCreator.close();
	}
}
